<?php

namespace App\Admin\Controllers;

use App\Http\Controllers\Controller;
use Encore\Admin\Controllers\Dashboard;
use Encore\Admin\Facades\Admin;
use Encore\Admin\Layout\Column;
use Encore\Admin\Layout\Content;
use Encore\Admin\Layout\Row;
use App\Helper\Build\Build;
use App\Models\Site;
use App\Models\News\NewsClass;

class HomeController extends Controller
{
    public function index()
    {
        // dd(Auction::limit(20)->get());
        return Admin::content(function (Content $content) {

            $content->header('文档');
            $content->description('调取参数文档');

            $content->row(view('admin.tools.home'));

            $content->row(function (Row $row) {

                $row->column(12, function (Column $column) {
                    $column->append('');
                });
            });
        });
    }
    //公共生成
    public function build_common()
    {
        $filed = request()->get('filed', '');
        $id = request()->get('id', 0);
        if($filed == '')return ['msg'=> '错误'];
        
        switch ($filed) {
            case 'NewsClass':
                # code...
                return NewsClass::build_list_class($id);
                break;
            
            default:
                # code...
                break;
        }
    }
	//生成首页
	public function build_index()
	{
        //获取默认首页
        $info = Site::default_site();
        if(!$info)return ['msg'=> '请设置默认首页'];
		$Build = new Build($info);
		return $Build->index();
	}
	//更改主题
	public function skin()
	{
		Admin::user()->skin = request()->get('skin');
		Admin::user()->save();
		return Admin::user();
	}
}